package ex.tableapi;

import org.apache.flink.table.api.Table;

import static org.apache.flink.table.api.Expressions.$;

public class Ex01 extends ApiFrame {

    private String outName = "printOutTable";
    private String createPrintOutDDL = "CREATE TABLE printOutTable (" +
            "a STRING, " +
            "b BIGINT " +
            ") WITH (" +
            " 'connector' = 'print' " +
            ")";

    public static void main(String[] args) {
        Ex01 demo = new Ex01();
        demo.getEnv();
        Table orders = demo.registerMysql("myorder", "orders");
        demo.registerConsole(demo.createPrintOutDDL, demo.outName);

        Table result1 = orders
                .groupBy($("a"))
                .select($("a"), $("b").count().as("cnt"));

        result1.executeInsert(demo.outName);
    }
}
